package page;

import java.util.List;

/**
 * 分页对象
 *
 * @param <T> 传递的泛型对象
 */
public class Pager<T> {
    /**
     * 每页显示条数
     */
    private int size;
    /**
     * 分页的起始页
     */
    private int offset;
    /**
     * 查询的总数
     */
    private long total;

    /**
     * 总页数
     */
    private int countPage;
    /**
     * 分页的结果数据
     */
    private List<T> datas;

    public Pager() {
    }

    public Pager(int total, List<T> datas) {
        this.total = total;
        this.datas = datas;
        this.size = SystemContext.getPageSize();
        String count = String.valueOf(this.total%this.size==0?this.total/this.size:this.total/this.size+1);
        this.countPage = Integer.parseInt(count);
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public int getOffset() {
        return offset;
    }

    public void setOffset(int offset) {
        this.offset = offset;
    }

    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
    }

    public int getCountPage() {
        return countPage;
    }

    public void setCountPage(int countPage) {
        this.countPage = countPage;
    }

    public List<T> getDatas() {
        return datas;
    }

    public void setDatas(List<T> datas) {
        this.datas = datas;
    }
}
